import com.medical.blood.entity.User;
import com.medical.blood.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;

@RestController
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("/user/update")
    public Map<String, Object> updateUserInfo(@RequestBody User user) {
        Map<String, Object> responseMap = new HashMap<>();
        try {
            userInfoService.updateUserInfo(user);
            responseMap.put("message", "用户信息更新成功");
            responseMap.put("success", true);
        } catch (Exception e) {
            responseMap.put("message", "用户信息更新失败：" + e.getMessage());
            responseMap.put("success", false);
        }
        return responseMap;
    }
}